<template>
  <el-cascader
    :value="value"
    :options="terrData"
    size="mini"
    :props="{label:'name',value:'id'}"
    @change="change"
  />
</template>

<script>

import { reqGetDepts } from '@/api/department'
import { translateTreeData } from '@/utils/index'
export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      terrData: []
    }
  },
  computed: {

  },
  watch: {

  },
  async  created() {
    const res = await reqGetDepts()
    this.terrData = translateTreeData(res.data, 0)
  },
  mounted() {

  },
  methods: {
    change(val) {
      this.$emit('input', val[val.length - 1])
    }
  }
}
</script>

<style scoped>

</style>
